﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using LuKou.Member;
using LuKou.Member.Domains;
using LuKou.Shopspace;
using LuKou.Shopspace.Domains;
using LuKou.Web.BLL;
using LuKou.Web.BLL.Service;
using LuKou.Web.Controllers.Base;
using LuKou.Web.Core;
using LuKou.Web.Form;
using LuKou.Web.Helper;

namespace LuKou.Web.Controllers.Website
{
    /// <summary>
    /// 店铺页面控制器
    /// </summary>
    public class StoreController : WebBaseController
    {
        /// <summary>
        /// 店铺首页
        /// </summary>
        /// <param name="id">店铺id</param>
        /// <returns></returns>
        public ActionResult Index(long id)
        {
            Shop shop = ShopService.GetShop(id);
            if (shop == null)
            {
                return this.RedirectIndex();
            }

            return View("Index", shop);
        }

        /// <summary>
        /// 店铺动态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult News(long id)
        {
            Shop shop = ShopService.GetShop(id);
            if (shop == null)
            {
                return this.RedirectIndex();
            }

            return View("News", shop);
        }

        /// <summary>
        /// 店铺介绍
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Intro(long id)
        {
            Shop shop = ShopService.GetShop(id);
            if (shop == null)
            {
                return this.RedirectIndex();
            }

            return View("Intro", shop);
        }

        /// <summary>
        /// 商家列表
        /// </summary>
        public ActionResult List(int? pageindex, string orderby)
        {
            int pageIndex = pageindex ?? 1;

            List<string> order = new List<string>();
            if (!string.IsNullOrEmpty(orderby))
            {
                order.Add(orderby);
            }
            return View(ShopService.GetShopList(EShopType.VendorShop, pageIndex, 20, order));
        }

        /// <summary>
        /// 代发列表
        /// </summary>
        public ActionResult Agent(int? pageindex)
        {
            int pageIndex = pageindex ?? 1;
            return View(ShopService.GetShopList(EShopType.ShippedShop, pageIndex, 20, null));
        }

        /// <summary>
        /// 摄影店列表
        /// </summary>
        public ActionResult Photography(int? pageindex)
        {
            int pageIndex = pageindex ?? 1;
            return View(ShopService.GetShopList(EShopType.PhotographyShop, pageIndex, 20, null));
        }
    }
}
